package share.seckill.module.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import share.seckill.module.domain.User;
import share.seckill.module.mapper.UserDao;

@Service
public class UserService {
    @Autowired
    protected UserDao userDao;

    public User getById(int id){
        return userDao.getByUserId(id);
    }

    @Transactional
    public boolean tx(){
        User user = new User();
        user.setId(2);
        user.setUsername("user1");
        user.setPassword("paswer");
        userDao.insert(user);

        User user2 = new User();
        user2.setId(2);
        user2.setUsername("user2");
        user2.setPassword("paswer2");
        userDao.insert(user2);
        return true;
    }
}
